import React from 'react';
import {
  Form,
  Input,
  Button,
  Table,
  Icon,
  Radio,
  InputNumber,
  Checkbox,
  Modal,
  message,
  notification,
  Affix,
  Upload,
  Select
} from 'antd';

import InnerTable from 'components/DBTable/InnerTable.js';
import ajax from '../../../utils/ajax';

const FormItem = Form.Item;
const ButtonGroup = Button.Group;
const Option = Select.Option;

var _this;

/**
 * 内部表格组件
 */
class ImportExcelInnerTable extends InnerTable {

  /**
   * 构造器，好像是用来初始化的？
   * @param props
   */
  // constructor(props) {
  //     super(props);
  //     this.state.moduleName = 'museum';
  //     this.state.museumManageUsers = [];
  //     this.initManageUsersData(this.props);

  //   }

  /**
   * 这里好像是用来配置那些按钮之类的
   * @returns {Array}
   */
  prepareToolBar = function () {

    var items = [];
     if (this.props.tableConfig.showUpload) {
       items.push(<Button key='audioUpBtn' type="primary"  onClick={this.onClickUpLoadExcel}>
      <Icon type="edit"/>导入数据
    </Button>);
     }


    return items;

  }

onClickUpLoadExcel = () =>{

    this.setState({modalVisible: true, fileList:[],modalTitle: '导入数据', modalState: this.modalActionState.Insert});
  }


//  handleModalOk = () => {
//    this.setState({ modalVisible: false });
//  }

  hideModal = () => {
    this.setState({ modalVisible: false });
  }

 onFileUpChange = (info)=>{
    let fileList = info.fileList;

    if (fileList.length > 1) {
      fileList = fileList.slice(-1); //最多只能有一个文件
    }


    if (info.file.response) {
      fileList = fileList.map((file) => {
        file.url = file.response.data.url;
        return file;
      });
      let url = info.file.response.data.url;
      let name = info.file.name;
      this.props.form.setFieldsValue({url:url});
      this.props.form.setFieldsValue({name:name});
    }

    this.setState({ fileObjs: fileList });
    this.setState({url: url});
  }

}

export default ImportExcelInnerTable;
